package JUnit;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import Model.*;
import org.junit.*;
import static org.junit.Assert.*;


/**
 * Tests the Event class for completeness.
 * 
 * @author John Frederick
 * @version 1.0 11/14/2012
 */
public class JohnEventTest {

	Event event = new Event();
	int testIterations = 1000;
	
	/**
	 * This tests the Event.nextEvent method using 1000 iterations to ensure that all cases are covered.
	 */
	@Test
	public void testNextEvent(){
		HashMap<String,Object> output;
		for(int i=0;i<testIterations;i++){
			output = (HashMap<String, Object>) event.nextEvent();
			Assert.assertNotNull("Event returned a null output", output);
			Assert.assertNotNull("Event returned a null value", output.get("value"));
			int value = (Integer) output.get("value");
			if(value == 0){
				
			} else {
				Assert.assertNotNull("Event Title is null", output.get("title"));
				Assert.assertNotNull("Event Message is null", output.get("message"));

				if(value == 1){//market event
					Assert.assertNotNull("Market Event: TradeGood is null", output.get("tradegood"));
					int quantity = ((TradeGood) output.get("tradegood")).getQuantity();
					if(quantity < 1 || quantity > 6){
						Assert.fail();
					}
				} else if(value == 2){//space hobo event
					
				} else if(value == 3){//wise sage event
					
				} else {
					Assert.fail("value returned is out of intended range");
				}
			}
		}
	}//end method testNextEvent
}//end class JohnEventTest
